@isTest(SeeAllData=true)
public class Test_ctrl_ServiceLetterPDF {

    private static Request__c newRequest;
    
    public static void createData() {
        Account newAccount = new Account();
        newAccount.Name = 'New Account';
        newAccount.Mobile__c = '1122452';
        insert newAccount;
        
        Transaction_Types__c newTransacrionType = new Transaction_Types__c();
        newTransacrionType.Application_Package__c = 'Service Letter';
        newTransacrionType.Application_Type__c = 'Certificate';
        newTransacrionType.Transaction_Description__c = 'Certificate of Incorporation';
        newTransacrionType.isMobile__c = True;
        newTransacrionType.Active__c = True;
        insert newTransacrionType;
        
        Requested_For__c newRequestedFor = new Requested_For__c();
        newRequestedFor.isActive__c = True;
        newRequestedFor.Type__c = 'Vehicle';
        newRequestedFor.Name = 'Ajman Traffic Department';
        insert newRequestedFor;
        
        RecordType requestRecordType = [SELECT Id FROM RecordType WHERE SObjectType = 'Request__c' AND DeveloperName LIKE '%Certificate%' LIMIT 1];
        newRequest = new Request__c();
        newRequest.RecordTypeId = requestRecordType.Id;
        newRequest.Company__c = newAccount.Id;
        newRequest.Transaction_Type__c = newTransacrionType.Id;
        newRequest.Delivery_Method__c = 'Self Pickup';
        newRequest.PRO_Mobile_No__c  = '22ss';
        //newRequest.Requested_For__c = newRequestedFor.Id;
        insert newRequest;
        
        newRequest = [SELECT Id, Name FROM Request__c WHERE Id = :newRequest.id];

    }
    
    // Methods for testing
    public static testMethod void testMobileAppRequestSearchExtension() 
    {
        createData();
        
        MobileAppRequestSearchExtension.searchRequests(newRequest.Name);
        //newRequest = new Request__c();
        
        PageReference pageRef = Page.vfp_ServiceLetter;   
        Test.setCurrentPage(pageRef);        
        
        ApexPages.currentPage().getParameters().put('Id', newRequest.Id);
        
        ApexPages.StandardController requestStandardController = new ApexPages.StandardController(newRequest);
        ctrl_ServiceLetterPDF serviceLetterExtension = new ctrl_ServiceLetterPDF(requestStandardController);
        
    }
}